package com.example.tourism.service.impl;


import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class RabbitMQSenderService {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    public void send(String msg) {
        // 设置死信时间
        rabbitTemplate.convertAndSend("simple.direct", "hi", msg, message -> {
            message.getMessageProperties().setExpiration("1800000"); // 30分钟
            return message;
        });
        //System.out.println("成功发送信息");
    }
}
